package com.supermap.application.service;

import com.supermap.application.utils.HttpClientUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName MessageManageService
 * @Description TODO
 * @Author HEKE
 * @Date 2019/3/5 21:03
 */

@Service
public class MessageManageService {

    @Value("${message-address}")
    private String messageAddress;

    /**
     *
     * @return
     */
    public String getUserIdByPhone(String phone){
        String[] split = phone.split(",");
        String ids = "";
        for (int i = 0; i < split.length; i++){
            String getUrl = messageAddress + "/zhxq/ws/getAppUserIdByPhone?phone=" + split[i];
            String s = HttpClientUtils.doGet(getUrl);
            ids = ids + s + ",";
        }
        return ids;
    }


    public String sendMsgToApp(String title, String content, String ids, String appHandUrl){

        String getUrl = messageAddress + "/zhxq/ws/sendMsgToApp?title="+ title +"&content=" + content + "&accounts=" + ids + "&appHandUrl=" + appHandUrl;
        String s = HttpClientUtils.doGet(getUrl);
        return s;
    }
}
